package com.wn.production.web;

import com.wn.common.PageBean;
import com.wn.common.ResponseEntity;
import com.wn.entity.MonthlyPlan;
import com.wn.production.service.MonthlyPlanService;
import com.wn.production.vo.MonthlyPlanVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/production/monthlyplan")
@Slf4j
@Validated
public class MonthlyPlanController {
    @Autowired
    private MonthlyPlanService monthlyPlanService;
    @RequestMapping("add")
    public ResponseEntity add(@Validated MonthlyPlan monthlyPlan) {
        monthlyPlanService.insert(monthlyPlan);
        return ResponseEntity.success;
    }

    @RequestMapping("getByCondition")
    public ResponseEntity getByCondition(@RequestBody MonthlyPlanVo monthlyPlanVo) {
        PageBean<MonthlyPlan> pageBean = monthlyPlanService.getByCondition(monthlyPlanVo);
        return new ResponseEntity(pageBean);
    }
}
